Imports System.Data.SqlClient
Imports ModuloAdministraciondeEnvios.Entity
Imports ModuloAdministraciondeEnvios.BusinessLogicLayer


Namespace DataAccessLayer
    Public Class DataLocalidad

        Inherits Localidad
        Implements ILocalidad



        Public Function TraerLocalidadesTodas() As System.Data.DataSet Implements BusinessLogicLayer.ILocalidad.TraerLocalidadesTodas
            Try

                Dim Conecta As New SqlConnection(StringConecta)
                Comando = New SqlCommand(StringComando, Conecta)
                Comando.CommandText = "Localidad_SelectAll"
                Comando.CommandType = CommandType.StoredProcedure

                Dim Adapter As SqlDataAdapter = New SqlDataAdapter(Comando)
                Dim Ds As DataSet = New DataSet(Comando.CommandText)

                Adapter.Fill(Ds)

                Return Ds

            Catch ex As Exception

                MsgBox("No pudo por que " & ex.Message)

                Return Ds

            End Try

        End Function


        Public Function TraerCodigoPostalDeLocalidad(ByVal IdLocalidad As Integer) As String Implements BusinessLogicLayer.ILocalidad.TraerCodigoPostalDeLocalidad

            Try



                Dim Conecta As New SqlConnection(StringConecta)
                Comando = New SqlCommand(StringComando, Conecta)
                Conecta.Open()

                Comando.CommandText = "Localidad_SelectRow"
                Comando.CommandType = CommandType.StoredProcedure


                Comando.Parameters.Add("@IDLocalidad", SqlDbType.Int, 4, "IDLocalidad").Value = IdLocalidad
                Comando.ExecuteNonQuery()


                Dim Adapter As SqlDataAdapter = New SqlDataAdapter(Comando)
                Dim Ds As DataSet = New DataSet(Comando.CommandText)

                Adapter.Fill(Ds)


                Return Ds.Tables(0).Rows(0).Item(0).ToString

            Catch ex As Exception

                MsgBox("No pudo por que " & ex.Message)

                Return ""

            End Try


        End Function


    End Class
End Namespace